var myjqgrid={};
/**
 * 刷新表格
 * @param selector 表格的选择器
 */
myjqgrid.reload=function(selector){
	var $grid=$(selector);
	$grid.jqGrid('setGridParam',{
		page:$grid.jqGrid('getGridParam','page')
	}).trigger('reloadGrid');
};

/**
 * jqgrid的beforeRequest.postData，也就是请求数据时参数
 * @param inputSelectors ,获取参数的目标input选择器，格式是用","相连接
 * 将获取这些input的name作为参数，其val()值作为值
 * 
 * @param data 默认参数，一般是gridKey
 */
myjqgrid.buildSearchData=function(inputSelectors,data){
	var selectors=inputSelectors.split(",");
	$.each(selectors,function(index,value){
		$input=$(value);
		data[$input.attr('name')]=$input.val();
	});
	return data;
};

myjqgrid.sendDeatilsId=function(gridKey,basePath){
	var $gird=$("#grid-"+gridKey);
	var detailsId=$gird.jqGrid('getGridParam','selarrrow');
	
	var cancelShowDetails=true;
	
	if(detailsId&&detailsId.length!=0){
		if(detailsId.length==1){
			cancelShowDetails=false;
			$.ajax({
				url:basePath+"/controller/jqgrid/setDetailsId?gridKey="+gridKey+"&detailsId="+detailsId[0],
				async:false,
				success:function(){
				}
			});		
		}else{
			$.jBox.alert('只能选择一项!', '提示');
		}
	}else{
		$.jBox.alert('请选择一项!', '提示');
	}
	
	if(cancelShowDetails){
		$.ajax({
			url:basePath+"/controller/jqgrid/cancelShowDetails?gridKey="+gridKey+"",
			async:false,
			success:function(){
			}
		});	
	}
};